package com.ikun.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import com.ikun.entity.Visitors;
import com.ikun.service.VisitorsService;
import com.ikun.util.Result;

import io.swagger.v3.oas.annotations.tags.Tag;

/**
 * @ClassName: VisitorsController
 * @Author: 吴思伟
 * @CreateTime: 2025-03-26 10:08
 * @Description: 访客管理相关
 */
@Controller
@RequestMapping("/visitors")
@Tag(name = "访客模块", description = "管理员访客相关接口")
public class VisitorsController {
    @Autowired
    private VisitorsService visitorsService;

    @GetMapping("/showAllVisitors")
    @ResponseBody
    public Result showAllVisitors(@RequestParam(required = false) Integer managerId) {
        return Result.success(visitorsService.findAllVisitors(managerId));
    }

    @GetMapping("/showAllByManagers")
    @ResponseBody
    public Result showAllByManagers(String managersName) {
        return Result.success(visitorsService.findAllByManagers(managersName));
    }

    @PostMapping("/addVisitor")
    @ResponseBody
    public Result addVisitor(@RequestBody Visitors visitors) {
        return Result.success(visitorsService.addVisitors(visitors));
    }

    @PostMapping("/updateVisitorsStatus")
    @ResponseBody
    public Result updateStatus(@RequestParam Integer visitorId) {
        return Result.success(visitorsService.updateStatus(visitorId));
    }

}
